* Introduces two metadata files with various bits of project information.
* Fetches and builds your project’s dependencies.
-* Invokes `rustc` or another build tool with the correct parameters to build your project.
+* Invokes `rustc` or another build tool with the correct parameters to build
+ your project.
* Introduces conventions to make working with Rust projects easier.
# Creating a new project
You’ll now notice a new file, `Cargo.lock`. It contains information about our
dependencies. Since we don’t have any yet, it’s not very interesting.
-Once you’re ready for release, you can use `cargo build --release` to compile your files with optimizations turned on:
+Once you’re ready for release, you can use `cargo build --release` to compile
+your files with optimizations turned on:
<pre><code class="language-shell"><span class="gp">$</span> cargo build --release
<span style="font-weight: bold"
* The default library file is `src/lib.rs`.
* The default executable file is `src/main.rs`.
* Other executables can be placed in `src/bin/*.rs`.
-* Integration tests go in the `tests` directory (unit tests go in each file they're testing).
+* Integration tests go in the `tests` directory (unit tests go in each file
+ they're testing).
* Examples go in the `examples` directory.
* Benchmarks go in the `benches` directory.
`Cargo.toml` and `Cargo.lock` serve two different purposes. Before we talk
about them, here’s a summary:
-* `Cargo.toml` is about describing your dependencies in a broad sense, and is written by you.
-* `Cargo.lock` contains exact information about your dependencies. It is maintained by Cargo and should not be manually edited.
+* `Cargo.toml` is about describing your dependencies in a broad sense, and is
+ written by you.
+* `Cargo.lock` contains exact information about your dependencies. It is
+ maintained by Cargo and should not be manually edited.
If you’re building a library that other projects will depend on, put
`Cargo.lock` in your `.gitignore`. If you’re building an executable like a
# Further reading
-Now that you have an overview of how to use cargo and have created your first crate, you may be interested in:
+Now that you have an overview of how to use cargo and have created your first
+crate, you may be interested in:
* [Publishing your crate on crates.io](crates-io.html)
* [Reading about all the possible ways of specifying dependencies](specifying-dependencies.html)
*.rs
```
-To structure your code after you've created the files and folders for your project, you should remember to use Rust's module system, which you can read about in [the book](https://doc.rust-lang.org/book/crates-and-modules.html).
+To structure your code after you've created the files and folders for your
+project, you should remember to use Rust's module system, which you can read
+about in [the book](https://doc.rust-lang.org/book/crates-and-modules.html).
# Examples
Files located under `examples` are example uses of the functionality provided by
the library. When compiled, they are placed in the `target/examples` directory.
-They can compile either as executables (with a `main()` function) or libraries and pull in the library by using `extern crate <library-name>`. They are compiled when you run
-your tests to protect them from bitrotting.
+They can compile either as executables (with a `main()` function) or libraries
+and pull in the library by using `extern crate <library-name>`. They are
+compiled when you run your tests to protect them from bitrotting.
You can run individual executable examples with the command `cargo run --example
<example-name>`.
crate-type = ["staticlib"]
```
-You can build individual library examples with the command `cargo build --example <example-name>`.
+You can build individual library examples with the command
+`cargo build --example <example-name>`.
# Tests